import React, { Component } from 'react'
/* 引入antd组件 */
import { Button } from 'antd-mobile';
import 'antd-mobile/dist/antd-mobile.css';
import axios from "axios"

/* 引入模块样式 */
import Selfcss from "../scss/Self.module.scss"
export default class Self extends Component {
    state = {
        islogin: false
    }
    handlelogin = () => {
        this.props.history.push("/login")
        // console.log(this.props);
    }
    handleloginout = () => {
        localStorage.removeItem('MyToken')
        this.setState({
            islogin: false
        })
    }
    componentDidMount() {
        if (localStorage.getItem("MyToken")) {
            this.setState({
                islogin: true
            })
        }
    }
    handleaxios = () => {
        console.log("进入请求");
        axios.post("https://gwbk.zhongan.com/appapi/dm-account/otp/sendSmsCode", {
            phone: 18779447940,
            checkUser:true
        }).then(res => {
            console.log(res);
        })
    }
    render() {
        return (
            <div className={Selfcss.Myself}>
                <div className={Selfcss.top}>
                    {this.state.islogin ? (
                        /* 头像 */
                        <div>
                            <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1604325463691&di=efc594d9f394476b35edbde9721cfa85&imgtype=0&src=http%3A%2F%2Fpic4.zhimg.com%2F50%2Fv2-f4d4d08ea36ee8c52741752e04d3e947_hd.jpg" alt="" />
                            <Button className={Selfcss.loginout} onClick={this.handleloginout}>退出登录</Button></div>
                    ) : (
                            <Button onClick={this.handlelogin} className={Selfcss.loginbnt}>立即登入</Button>
                        )}
                </div>
                <div className={Selfcss.myOrder}>
                    我的订单
                     <span>查看所有订单》</span>
                </div>
                <div className={Selfcss.myNav}>
                    <div className={Selfcss.myNavItem}>
                        <p className="iconfont">&#xe60b;</p>
                        待付款
                    </div>
                    <div className={Selfcss.myNavItem}>
                        <p className="iconfont">&#xe637;</p>
                        待收货
                    </div>
                    <div className={Selfcss.myNavItem}>
                        <p className="iconfont">&#xe65e;</p>
                        已收货
                    </div>
                    <div className={Selfcss.myNavItem}>
                        <p className="iconfont">&#xe65f;</p>
                        已取消
                    </div>
                    <div className={Selfcss.myNavItem}>
                        <p className="iconfont">&#xe68f;</p>
                        售后
                    </div>
                </div>
                <div className={Selfcss.myList}>
                    <div className={Selfcss.myListItem}>
                        我的收藏
                     <span>{">"}</span>
                    </div>
                    <div className={Selfcss.myListItem}>
                        联系客服
                     <span>{">"}</span>
                    </div>
                    <div className={Selfcss.myListItem}>
                        关于我们
                     <span>{">"}</span>
                    </div>
                    <div className={Selfcss.myListItem} onClick={this.handleaxios}>
                        设置
                     <span>{">"}</span>
                    </div>
                </div>
            </div>
        )
    }
}
